<!DOCTYPE html>



  


<html class="theme-next pisces use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<meta name="theme-color" content="#222">
<meta name="referrer" content="same-origin">
<meta name="referrer" content="no-referrer" />








<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />







<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.4" rel="stylesheet" type="text/css" />


  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png?v=5.1.4">


  <link rel="mask-icon" href="/images/logo.svg?v=5.1.4" color="#222">





  <meta name="keywords" content="Docker," />










<meta name="description" content="功能&amp;emsp;&amp;emsp;在拥抱Docker（三）基础原理之Namespaces中讲述了构建Linux容器的虚拟技术Namespaces，它可以帮助进程隔离出自己独立的空间。但是容器内的进程不应该随心所欲地获取系统资源（cpu、内存、磁盘、网络等），所以需要有一种控制手段来限制或者隔离这些资源，这就是Linux CGroups做的事。Linux CGroups全称Linux Control Gr">
<meta name="keywords" content="Docker">
<meta property="og:type" content="article">
<meta property="og:title" content="拥抱Docker（四）基础原理之CGroups">
<meta property="og:url" content="http://yoursite.com/2019/07/15/拥抱Docker（四）基础原理之CGroups/index.html">
<meta property="og:site_name" content="矩阵编程">
<meta property="og:description" content="功能&amp;emsp;&amp;emsp;在拥抱Docker（三）基础原理之Namespaces中讲述了构建Linux容器的虚拟技术Namespaces，它可以帮助进程隔离出自己独立的空间。但是容器内的进程不应该随心所欲地获取系统资源（cpu、内存、磁盘、网络等），所以需要有一种控制手段来限制或者隔离这些资源，这就是Linux CGroups做的事。Linux CGroups全称Linux Control Gr">
<meta property="og:locale" content="zh-Hans">
<meta property="og:image" content="http://ww1.sinaimg.cn/large/639cfad5ly1g4yb8ngszlj20ye0nq75v.jpg">
<meta property="og:updated_time" content="2019-10-24T16:22:00.000Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="拥抱Docker（四）基础原理之CGroups">
<meta name="twitter:description" content="功能&amp;emsp;&amp;emsp;在拥抱Docker（三）基础原理之Namespaces中讲述了构建Linux容器的虚拟技术Namespaces，它可以帮助进程隔离出自己独立的空间。但是容器内的进程不应该随心所欲地获取系统资源（cpu、内存、磁盘、网络等），所以需要有一种控制手段来限制或者隔离这些资源，这就是Linux CGroups做的事。Linux CGroups全称Linux Control Gr">
<meta name="twitter:image" content="http://ww1.sinaimg.cn/large/639cfad5ly1g4yb8ngszlj20ye0nq75v.jpg">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Pisces',
    version: '5.1.4',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://yoursite.com/2019/07/15/拥抱Docker（四）基础原理之CGroups/"/>





  <title>拥抱Docker（四）基础原理之CGroups | 矩阵编程</title>
  





  <script type="text/javascript">
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "https://hm.baidu.com/hm.js?7d29e6fba8e07d1a8af2414a20e5f2a6";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>




</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">矩阵编程</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle"></p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-主页">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-主页"></i> <br />
            
            主页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-分类"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-所有文章">
          <a href="/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-文章"></i> <br />
            
            所有文章
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2019/07/15/拥抱Docker（四）基础原理之CGroups/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="matrix">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="矩阵编程">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">拥抱Docker（四）基础原理之CGroups</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2019-07-15T08:58:41+08:00">
                2019-07-15
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/Docker/" itemprop="url" rel="index">
                    <span itemprop="name">Docker</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
              <span class="post-comments-count">
                <span class="post-meta-divider">|</span>
                <span class="post-meta-item-icon">
                  <i class="fa fa-comment-o"></i>
                </span>
                <a href="/2019/07/15/拥抱Docker（四）基础原理之CGroups/#comments" itemprop="discussionUrl">
                  <span class="post-comments-count disqus-comment-count"
                        data-disqus-identifier="2019/07/15/拥抱Docker（四）基础原理之CGroups/" itemprop="commentCount"></span>
                </a>
              </span>
            
          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <h4 id="功能"><a href="#功能" class="headerlink" title="功能"></a>功能</h4><p>&emsp;&emsp;在<a href="/2019/07/08/拥抱Docker（三）基础原理之Namespaces">拥抱Docker（三）基础原理之Namespaces</a>中讲述了构建Linux容器的虚拟技术Namespaces，它可以帮助进程隔离出自己独立的空间。但是容器内的进程不应该随心所欲地获取系统资源（cpu、内存、磁盘、网络等），所以需要有一种控制手段来限制或者隔离这些资源，这就是Linux CGroups做的事。Linux CGroups全称Linux Control Groups，由全称可以看出，他是一种分组的机制，一个cgroup包含一组控制，可以在这个cgroup上增加各种参数配置来管理一组资源控制的模块，包含以下的功能：</p>
<ol>
<li>限制进程组的资源使用量（Resource limiting）。比如可以为进程组设定内存使用量，一旦进程组超出这个量，就会触发内存溢出的错误。</li>
<li>进程组的优先控制（Prioritization）。有些进程组可以给予更高的cpu利用率，或者是磁盘的I/O吞吐。</li>
<li>统计进程组使用的资源数量（Accounting）。比如可以用于一些计费功能。</li>
<li>进程组控制（Control）。可以执行挂起进程、恢复执行进程的行为。</li>
</ol>
<a id="more"></a>
<h4 id="组件"><a href="#组件" class="headerlink" title="组件"></a>组件</h4><p>&emsp;&emsp;整个CGroups系统包含以下组件：</p>
<ul>
<li>任务（task）。在CGroups中任务就是系统的一个进程。</li>
<li>控制组（control group）。CGroups中的资源控制都以cgroup为单位实现。cgroup表示按某种资源控制标准划分而成的任务组，包含一个或多个子系统。一个任务（task）可以加入某个cgroup，也可以从某个cgroup迁移到另外一个cgroup。</li>
<li>层级树（hierarchy）。由一系列cgroup以一个树状结构排列而成，每个hierarchy通过绑定对应的subsystem进行资源调度。hierarchy中的cgroup节点可以包含零或多个子节点，子节点继承父节点的属性。整个系统可以有多个hierarchy。</li>
<li>子系统（subsystem）。CGroups的资源控制模块，一个子系统就是一个资源控制器，比如cpu子系统可以控制cpu时间分配。子系统必须附加（attach）到一个层级上才能起作用，一个子系统附加到某个层级以后，这个层级上的所有控制组都受到这个子系统的控制。子系统包含如下几项：<ul>
<li>blkio 设置对块设备（比如硬盘、USB等）输入/输出的访问限制。</li>
<li>cpu 对cpu资源的调度策略的控制。</li>
<li>cpuacct 统计进程对cpu的使用情况。</li>
<li>cpuset 分​​​配独​​​立​​​cpu（在​​​多​​核系​​​统​​​上）和​​​内​​​存​​​节​​​点​​​。​​​</li>
<li>devices 控制进程能够访问某些设备。</li>
<li>freezer 可以挂起或者恢复cgroup中的进程。</li>
<li>memory 可以限制进程的memory资源使用量。</li>
<li>net_cls 标记cgroup中进程的网络数据包，然后可以使用tc模块（traffic control）对数据包进行限流、监控等。</li>
<li>net_prio 设计网络流量的优先级。</li>
<li>ns 使不同cgroup下面的进程使用不同的namespace。</li>
</ul>
</li>
</ul>
<p>各组件之间的关系如下：<br><img src="http://ww1.sinaimg.cn/large/639cfad5ly1g4yb8ngszlj20ye0nq75v.jpg" alt></p>
<p>上图每一个层级都是一颗树的结构，树的每一个节点是一个cgroup（cpu_cgroup、memory_cgroup…）。层级A（Hierarchy A）attach了cpu子系统（subsystem）和cpuacct子系统，当前层级中的cgroup就可以对cpu资源进行限制，并且可以统计cpu的使用情况。层级B（Hierarchy B）attach了memory子系统，当前层级中的cgroup就可以对memory资源进行限制。上面cpu、memory通过Task关联，这样该Task组既有cpu的限制又有Memory的限制。</p>
<h4 id="一个限制cpu的示例"><a href="#一个限制cpu的示例" class="headerlink" title="一个限制cpu的示例"></a>一个限制cpu的示例</h4><p>&emsp;&emsp;Linux已经把CGroups做成了一个file system，可以通过mount去实现一个例子。现在我想实现一个cpu限制的例子，可以先看一下cpu子系统有没有被挂载：<br><figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">[root@VM_0_12_centos ~]<span class="comment"># mount|grep cpu</span></span><br><span class="line">cgroup on /sys/fs/cgroup/cpu,cpuacct <span class="built_in">type</span> cgroup (rw,nosuid,nodev,noexec,relatime,cpuacct,cpu)</span><br><span class="line">cgroup on /sys/fs/cgroup/cpuset <span class="built_in">type</span> cgroup (rw,nosuid,nodev,noexec,relatime,cpset)</span><br></pre></td></tr></table></figure></p>
<p>centos下系统已经mount了cpu子系统，现在只需要在<strong>/sys/fs/cgroup/cpu</strong>这个目录下创建子目录就可以了<br><figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line">[root@VM_0_12_centos ~]<span class="comment"># cd /sys/fs/cgroup/cpu</span></span><br><span class="line">[root@VM_0_12_centos cpu]<span class="comment"># ls</span></span><br><span class="line">cgroup.clone_children  cpuacct.usage         cpu.rt_runtime_us  system.slice</span><br><span class="line">cgroup.event_control   cpuacct.usage_percpu  cpu.shares         tasks</span><br><span class="line">cgroup.procs           cpu.cfs_period_us     cpu.stat           user.slice</span><br><span class="line">cgroup.sane_behavior   cpu.cfs_quota_us      notify_on_release</span><br><span class="line">cpuacct.stat           cpu.rt_period_us      release_agent</span><br><span class="line">[root@VM_0_12_centos cpu]<span class="comment"># mkdir cgroup-test</span></span><br><span class="line">[root@VM_0_12_centos cpu]<span class="comment"># cd cgroup-test/</span></span><br><span class="line">[root@VM_0_12_centos cgroup-test]<span class="comment"># ls</span></span><br><span class="line">cgroup.clone_children  cpuacct.usage_percpu  cpu.shares</span><br><span class="line">cgroup.event_control   cpu.cfs_period_us     cpu.stat</span><br><span class="line">cgroup.procs           cpu.cfs_quota_us      notify_on_release</span><br><span class="line">cpuacct.stat           cpu.rt_period_us      tasks</span><br><span class="line">cpuacct.usage          cpu.rt_runtime_us</span><br></pre></td></tr></table></figure></p>
<p>只要我们在<strong>/sys/fs/cgroup/cpu</strong>目录下创建文件夹，这个文件夹成为它的子cgroup，它们会自动继承父cgroup的属性。下面我们限制只能使用1个cpu的20%的时间：<br><figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">[root@VM_0_12_centos cgroup-test]<span class="comment"># sudo sh -c "echo 50000 &gt; cpu.cfs_period_us"</span></span><br><span class="line">[root@VM_0_12_centos cgroup-test]<span class="comment"># sudo sh -c "echo 10000 &gt; cpu.cfs_quota_us"</span></span><br></pre></td></tr></table></figure></p>
<p><strong>cfs_period_us</strong>配置时间周期长度，<strong>cfs_quota_us</strong>配置当前cgroup在设置的时间周期长度内所能使用的cpu时间数。这两个文件配合起来可以设置cpu的使用上限。两个文件的单位都是微秒（us），<strong>cfs_period_us</strong>的取值范围为1毫秒（ms）到1秒（s），<strong>cfs_quota_us</strong>的取值大于1ms即可，如果cfs_quota_us的值为-1（默认值），表示不受cpu时间的限制。这里设置每50ms能使用10ms的cpu时间，即使用一个cpu核心的20%。接下来我们写一个死循环的程序，使cpu最大程度地负载：<br><figure class="highlight go"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// dead.go</span></span><br><span class="line"><span class="keyword">package</span> main</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">func</span> <span class="title">main</span><span class="params">()</span></span>  &#123;</span><br><span class="line">	<span class="keyword">for</span> <span class="literal">true</span>&#123;</span><br><span class="line">	&#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure></p>
<p>运行这个程序，打开另外一个窗口查看cpu使用情况：<br><figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">[root@VM_0_12_centos go-workspace]<span class="comment"># go run dead.go</span></span><br><span class="line">[root@VM_0_12_centos ~]<span class="comment"># top</span></span><br><span class="line"></span><br><span class="line">  PID USER      PR  NI    VIRT    RES    SHR S %cpu %MEM     TIME+ COMMAND     </span><br><span class="line">13541 root      20   0  101844   4576    308 R 98.3  0.2   0:46.59 dead</span><br></pre></td></tr></table></figure></p>
<p>可以看到这个进程的cpu负载很高，接下来将这个dead.go的进程13541写入cgroup.procs中，这样这个进程的cpu使用将会得到限制：<br><figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">[root@VM_0_12_centos cgroup-test]<span class="comment">#sudo sh -c "echo 13541 &gt; cgroup.procs"</span></span><br><span class="line">[root@VM_0_12_centos ~]<span class="comment"># top</span></span><br><span class="line"></span><br><span class="line">  PID USER      PR  NI    VIRT    RES    SHR S %cpu %MEM     TIME+ COMMAND     </span><br><span class="line">13541 root      20   0  101844   4576    308 R 20.0  0.2   2:54.10 dead</span><br></pre></td></tr></table></figure></p>
<p>可以看到这里cpu一直在20%，再也没有上涨了。</p>
<h4 id="总结"><a href="#总结" class="headerlink" title="总结"></a>总结</h4><p>&emsp;&emsp;以上只是简单介绍了CGroups的概念和功能，还举了一个cpu限制的例子来说明，但是并没有深入CGroups的实现原理和使用要点，如果想要进一步了解CGroups，可以借鉴下面的文章。</p>
<h4 id="Reference"><a href="#Reference" class="headerlink" title="Reference"></a>Reference</h4><blockquote>
<p><a href="https://en.wikipedia.org/wiki/Cgroups" target="_blank" rel="noopener">《cgroups》</a><br><a href="https://files-cdn.cnblogs.com/files/lisperl/cgroups%E4%BB%8B%E7%BB%8D.pdf" target="_blank" rel="noopener">《Linux Cgroups 详解》</a><br><a href="https://tiewei.github.io/devops/howto-use-cgroup/" target="_blank" rel="noopener">《how to use cgroup》</a><br><a href="https://coolshell.cn/articles/17049.html" target="_blank" rel="noopener">《DOCKER基础技术：LINUX CGROUP》</a><br><a href="https://www.infoq.cn/article/docker-kernel-knowledge-cgroups-resource-isolation" target="_blank" rel="noopener">《Docker 背后的内核知识——cgroups 资源限制》</a></p>
</blockquote>

      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/Docker/" rel="tag"># Docker</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2019/07/11/Kubernetes学习笔记（一）一个例子展开/" rel="next" title="Kubernetes学习笔记（一）一个例子展开">
                <i class="fa fa-chevron-left"></i> Kubernetes学习笔记（一）一个例子展开
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2019/07/20/谈谈分布式缓存一致性/" rel="prev" title="谈谈分布式缓存一致性">
                谈谈分布式缓存一致性 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          

  
    <div class="comments" id="comments">
      <div id="disqus_thread">
        <noscript>
          Please enable JavaScript to view the
          <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a>
        </noscript>
      </div>
    </div>

  



        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview-wrap sidebar-panel">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <p class="site-author-name" itemprop="name">matrix</p>
              <p class="site-description motion-element" itemprop="description"></p>
          </div>

          <nav class="site-state motion-element">

            
              <div class="site-state-item site-state-posts">
              
                <a href="/archives">
              
                  <span class="site-state-item-count">47</span>
                  <span class="site-state-item-name">日志</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-categories">
                <a href="/categories/index.html">
                  <span class="site-state-item-count">18</span>
                  <span class="site-state-item-name">分类</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-tags">
                
                  <span class="site-state-item-count">19</span>
                  <span class="site-state-item-name">标签</span>
                
              </div>
            

          </nav>

          

          

          
          

          
          

          

        </div>
      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-4"><a class="nav-link" href="#功能"><span class="nav-number">1.</span> <span class="nav-text">功能</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#组件"><span class="nav-number">2.</span> <span class="nav-text">组件</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#一个限制cpu的示例"><span class="nav-number">3.</span> <span class="nav-text">一个限制cpu的示例</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#总结"><span class="nav-number">4.</span> <span class="nav-text">总结</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#Reference"><span class="nav-number">5.</span> <span class="nav-text">Reference</span></a></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; <span itemprop="copyrightYear">2021</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">matrix</span>

  
</div>


  <div class="powered-by">由 <a class="theme-link" target="_blank" href="https://hexo.io">Hexo</a> 强力驱动</div>



  <span class="post-meta-divider">|</span>



  <div class="theme-info">主题 &mdash; <a class="theme-link" target="_blank" href="https://github.com/iissnan/hexo-theme-next">NexT.Pisces</a> v5.1.4</div>
<div class=BbeiAn-info">
  浙ICP备 -
  <a href="http://www.beian.miit.gov.cn">18040498号</a>
  </a>
</div>




        







        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  












  
  
    <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>
  

  
  
    <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
  


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.4"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.4"></script>



  
  


  <script type="text/javascript" src="/js/src/affix.js?v=5.1.4"></script>

  <script type="text/javascript" src="/js/src/schemes/pisces.js?v=5.1.4"></script>



  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.4"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.4"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.4"></script>



  


  

    
      <script id="dsq-count-scr" src="https://luyun.disqus.com/count.js" async></script>
    

    
      <script type="text/javascript">
        var disqus_config = function () {
          this.page.url = 'http://yoursite.com/2019/07/15/拥抱Docker（四）基础原理之CGroups/';
          this.page.identifier = '2019/07/15/拥抱Docker（四）基础原理之CGroups/';
          this.page.title = '拥抱Docker（四）基础原理之CGroups';
        };
        var d = document, s = d.createElement('script');
        s.src = 'https://luyun.disqus.com/embed.js';
        s.setAttribute('data-timestamp', '' + +new Date());
        (d.head || d.body).appendChild(s);
      </script>
    

  




	





  














  





  

  

  

  
  

  

  

  

</body>
</html>
